/* ===================================
Michal Kowalczyk
2010 EZI
==================================== */

// Device code
extern "C" __global__ void ParMoveX(float* A, const float* B, int* C, float* v, int N)
{
	int i = blockDim.x * blockIdx.x + threadIdx.x;
	if (i < N)
	{
		if(C[i] == 0)
		{
			if(B[i] >= A[i])
			{
				A[i] += 0.2f * v[i];
				if(A[i] >= B[i])
					C[i] = 1;
			}
			else if(B[i] < A[i])
			{
				A[i] -= 0.2f * v[i];
				if(A[i] <= B[i])
					C[i] = 1;
			}
		}
	}
}

extern "C" __global__ void ParMoveZ(float* A, const float* B, int* C, float* v, int N)
{
	int i = blockDim.x * blockIdx.x + threadIdx.x;
	if (i < N)
	{
		if(C[i] == 0)
		{
			if(B[i] >= A[i])
			{
				A[i] += 0.2f * v[i];
				if(A[i] >= B[i])
					C[i] = 1;
			}
			else if(B[i] < A[i])
			{
				A[i] -= 0.2f * v[i];
				if(A[i] <= B[i])
					C[i] = 1;
			}
		}
	}
};

